<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button id="btn">click me!</button>
  </body>
  <script>
    function fn () {
      console.log(666)
    }
    function throttle (fn, delay) {
      let lastTime = new Date().getTime()
      let context = this
      let arg = arguments
      return function () {
        let curTime = new Date().getTime()
        if (curTime - lastTime >= delay) {
          fn().apply(context,arg)
          lastTime = new Date().getTime()
        }
      }
    }
    document.getElementById('btn').addEventListener('click', throttle(fn, 1000))
  </script>
</html>
